home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / snowbros.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  2KB  |  103 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12.  
  13. unsigned char *snowbros_spriteram;
  14.  
  15. size_t snowbros_spriteram_size;
  16.  
  17.  
  18. /* Put in case screen can be optimised later */
  19.  
  20. WRITE_HANDLER( snowbros_spriteram_w )
  21. {
  22.       COMBINE_WORD_MEM(&snowbros_spriteram[offset], data);
  23. }
  24.  
  25. READ_HANDLER( snowbros_spriteram_r )
  26. {
  27.     return READ_WORD(&snowbros_spriteram[offset]);
  28. }
  29.  
  30. void snowbros_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  31. {
  32.     int x=0,y=0,offs;
  33.  
  34.  
  35.     palette_recalc ();
  36.     /* no need to check the return code since we redraw everything each frame */
  37.  
  38.  
  39.     /*
  40.      * Sprite Tile Format
  41.      * ------------------
  42.      *
  43.      * Byte(s) | Bit(s)   | Use
  44.      * --------+-76543210-+----------------
  45.      *  0-5    | -------- | ?
  46.      *    6    | -------- | ?
  47.      *    7    | xxxx.... | Palette Bank
  48.      *    7    | .......x | XPos - Sign Bit
  49.      *    9    | xxxxxxxx | XPos
  50.      *    7    | ......x. | YPos - Sign Bit
  51.      *    B    | xxxxxxxx | YPos
  52.      *    7    | .....x.. | Use Relative offsets
  53.      *    C    | -------- | ?
  54.      *    D    | xxxxxxxx | Sprite Number (low 8 bits)
  55.      *    E    | -------- | ?
  56.      *    F    | ....xxxx | Sprite Number (high 4 bits)
  57.      *    F    | x....... | Flip Sprite Y-Axis
  58.      *    F    | .x...... | Flip Sprite X-Axis
  59.      */
  60.  
  61.     /* This clears & redraws the entire screen each pass */
  62.  
  63.       fillbitmap(bitmap,Machine->gfx[0]->colortable[0],&Machine->drv->visible_area);
  64.  
  65.     for (offs = 0;offs < 0x1e00; offs += 16)
  66.     {
  67.         int sx = READ_WORD(&snowbros_spriteram[8+offs]) & 0xff;
  68.         int sy = READ_WORD(&snowbros_spriteram[0x0a+offs]) & 0xff;
  69.         int tilecolour = READ_WORD(&snowbros_spriteram[6+offs]);
  70.  
  71.         if (tilecolour & 1) sx = -1 - (sx ^ 0xff);
  72.  
  73.         if (tilecolour & 2) sy = -1 - (sy ^ 0xff);
  74.  
  75.         if (tilecolour & 4)
  76.         {
  77.             x += sx;
  78.             y += sy;
  79.         }
  80.         else
  81.         {
  82.             x = sx;
  83.             y = sy;
  84.         }
  85.  
  86.         if (x > 511) x &= 0x1ff;
  87.         if (y > 511) y &= 0x1ff;
  88.  
  89.         if ((x>-16) && (y>0) && (x<256) && (y<240))
  90.         {
  91.             int attr = READ_WORD(&snowbros_spriteram[0x0e + offs]);
  92.             int tile = ((attr & 0x0f) << 8) + (READ_WORD(&snowbros_spriteram[0x0c+offs]) & 0xff);
  93.  
  94.             drawgfx(bitmap,Machine->gfx[0],
  95.                     tile,
  96.                     (tilecolour & 0xf0) >> 4,
  97.                     attr & 0x80, attr & 0x40,
  98.                     x,y,
  99.                     &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  100.         }
  101.     }
  102. }
  103.